import React from 'react';
import {Link} from "react-router-dom";
import {Button} from "antd";
import GUtils from "@/utils";


const Config = (Action) => {
    const Handlers = {
        delete({id, name}) {
            GUtils.confirm("删除",`确认删除菜单 [${name}] 吗?`,()=>{
                Action.delete(id);
            });

        }


    }
    const columns = [
        {title: 'ID',dataIndex: 'id',width: 150, render:(v)=><Link to={`detail/view?id=${v}`}>{v}</Link>},
        {title: '序号',dataIndex: 'order',width: 150},
        {title: '编码',dataIndex: 'code',width: 150},
        {title: '名称',dataIndex: 'name',width: 120,},
        {title: '路径',dataIndex: 'path',width: 220},
        {title: '操作',dataIndex: 'id',width: 150,render(id,vo){
            return <div>
                <Button type="link" danger onClick={Handlers.delete.bind(this,vo)}>删除</Button>

                <Link to={`detail/edit?id=${id}`} className="mr-8">编辑</Link>
                <Link to={`detail/view?id=${id}`}>查看详情</Link>
            </div>
        }},
    ];
    return {
        ...window.CONFIG.getPagerConfig(Action), columns
    };
};


export default Config;
